package com.bw.liuyushan.liuyushan20210904.MVP.Model;

import com.blankj.utilcode.util.NetworkUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.bw.liuyushan.liuyushan20210904.Entity.VideoBean;
import com.bw.liuyushan.liuyushan20210904.MVP.Contrack.IContrackTest;
import com.bw.liuyushan.liuyushan20210904.RequestAPI.API;
import com.bw.liuyushan.liuyushan20210904.Utils.RxJavaManager;
import com.bw.liuyushan.mvp_lib.Model.BaseModel;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

/**
 * Liuyushan20210904
 * file name is : BaseModelTest
 * created by Ender on 2021/9/4 8:19.
 * author : 刘雨杉
 * Describe:Model实现类的测试类
 */
public class BaseModelTest extends BaseModel implements IContrackTest.C_ModelTest {
    @Override
    public void askVideo(String url, Observer<VideoBean> observer) {
        if (NetworkUtils.isAvailableByPing()) {//网络判断是否连接
            ToastUtils.showShort("当前网络不可用");
        }else{
            //RxJava框架请求数据
            RxJavaManager.getInstance().getRetrofit().create(API.class)
                    .TestUrl(url)
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(observer);
        }

    }
}
